package com.example.lib_mvp.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.lib_mvp.base.HdMusicInfoBean;
import com.example.lib_mvp.R;

import java.util.List;

/**
 * 弹窗音频 列表
 */
public class PopMusicListAdapter extends BaseQuickAdapter<HdMusicInfoBean.ListDTO, BaseViewHolder> {
    public PopMusicListAdapter(@Nullable List<HdMusicInfoBean.ListDTO> data) {
        super(R.layout.hd_pop_music_list_item, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, HdMusicInfoBean.ListDTO item) {
        holder.setText(R.id.item_music_name_tv, item.getSong_title());
        ImageView item_music_play_img = holder.getView(R.id.item_music_status_img);
        item_music_play_img.setVisibility(item.isPlay() ? View.VISIBLE : View.GONE);
        Context context = holder.itemView.getContext();

        TextView item_music_name_tv = holder.getView(R.id.item_music_name_tv);
        item_music_name_tv.setTextColor(item.isPlay() ? context.getResources().getColor(R.color.hd_text)
                : context.getResources().getColor(R.color.black));
        holder.itemView.setBackgroundColor(item.isPlay() ? context.getResources().getColor(R.color.hd_music_item_bg)
                : context.getResources().getColor(R.color.transparent));
    }
}
